<?php
namespace App\Model;

class MallGoods extends Model
{
    // 表名
    protected $table = 'mall_goods';
    
    // 保护属性
    protected $guarded = [];
    
    protected $attributes = [
        'shop_id' => 0,
        'sort'    => 0,
        'money_settle' => 0,
        'day'       => 0,
        'day_count' => 0,
        'status'    => self::STATUS_NO
    ];
    
    // 格式
    protected $casts = [
        'images' => 'array'
    ];
    
    protected $dateFormat = 'U';
    
    // 状态
    const STATUS_NO    = 0;
    const STATUS_OK    = 1;
    
    // 分类
    public function mall()
    {
        return $this->belongsTo(Mall::class, 'mall_id');
    }
    
    // 商家
    public function shop()
    {
        return $this->belongsTo(MallShop::class, 'shop_id');
    }
}